<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:xh="http://www.w3.org/1999/xhtml"
 xmlns:xf="http://www.w3.org/2002/xforms"
 xmlns:ev="http://www.w3.org/2001/xml-events"
 xmlns:js="http://www.formsplayer.com/inlineScript"
>
	<head>
		<title>Bub</title>

		<script type="text/javascript" src="gadgets/common/scripts/events.js">/**/</script>

		<link rel="stylesheet" href="bub.css" type="text/css" media="screen" />

		<xf:model id="mdl-gadgets">
			<xf:instance id="inst-gadget">
				<gadget xmlns="">
					<type />
					<value />
				</gadget>
			</xf:instance>

			<xf:instance id="inst-params">
				<params xmlns="">
					<hub />
					<index />
					<position />
				</params>
			</xf:instance>

			<xf:instance id="inst-hub">
				<hub xmlns="" />
			</xf:instance>

			<xf:submission id="sbm-hub-load" method="get" replace="instance" instance="inst-hub" validate="false" serialize="false">
				<xf:resource value="instance('inst-params')/hub" />
			</xf:submission>

			<xf:instance id="inst-scripts">
				<scripts xmlns="">
					<retval />
				</scripts>
			</xf:instance>

			<xf:bind id="script-retval" nodeset="instance('inst-scripts')/retval" />

			<xf:action ev:event="xforms-ready">
				<xf:setvalue bind="script-retval" value="js:EVENTS_initUpdateHandler()" />

				<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-ready')" />
			</xf:action>

			<xf:action ev:event="backplane-update">
				<xf:setvalue ref="instance('inst-params')/hub" value="substring-before(instance('inst-gadget')/value, ' ')" />

				<xf:setvalue ref="instance('inst-params')/index" value="substring-before(substring-after(instance('inst-gadget')/value, ' '), ' ')" />

				<xf:setvalue ref="instance('inst-params')/position" value="substring-after(substring-after(instance('inst-gadget')/value, ' '), ' ')" />

				<xf:send submission="sbm-hub-load" />
			</xf:action>

			<xf:action ev:observer="sbm-hub-load" ev:event="xforms-submit-done">
				<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-show')" />
			</xf:action>
		</xf:model>
	</head>

	<body ondragenter="event.returnValue = false;" ondragover="event.returnValue = false;" ondrop="event.returnValue = false;">
		<div class="bub">
			<xf:group ref="(instance('inst-hub')/xh:body//*[contains(@typeof, 'hubbub:bub')])[number(instance('inst-params')/index)]">
				<xf:trigger appearance="minimal" class="item centre">
					<xf:label>
						<xf:output value="concat('&lt;img src=&quot;', xh:link[@rel = 'foaf:depiction']/@href, '&quot; alt=&quot;', *[@property = 'foaf:name'], '&quot; onerror=&quot;event.srcElement.src = &amp;quot;gadgets/friendfeed/default-user.png&amp;quot;;&quot; /&gt;')" />
					</xf:label>

					<xf:setvalue ev:event="DOMActivate" bind="script-retval" value="js:EVENTS_send('backplane-close')" />
				</xf:trigger>

				<xf:group ref="*[@property = 'friendfeed']" class="item north">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|friendfeed.feed|', instance('inst-gadget')/value))" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>

				<xf:group ref="*[@property = 'twitter']" class="item northeast">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|friendfeed.feed twitter|', instance('inst-gadget')/value))" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>

				<xf:group ref="*[@property = 'blog']" class="item east">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|friendfeed.feed blog|', instance('inst-gadget')/value))" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>

				<xf:group ref="*[@property = 'greader']" class="item southeast">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|friendfeed.feed googlereader|', instance('inst-gadget')/value))" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>

				<xf:group ref="*[@property = 'delicious']" class="item south">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|friendfeed.feed delicious|', instance('inst-gadget')/value))" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>

				<xf:group ref="*[@property = 'last.fm']" class="item southwest">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<!--
								TODO: Update the last.fm radio gadget to share the hub instance data, then change this xf:setvalue accordingly.
							-->
							<xf:setvalue ref="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|lastfm.radio|', string(.)), instance('inst-scripts')/retval)" value="''" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>

				<xf:group ref="*[@property = 'location']" class="item west">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|map|', instance('inst-gadget')/value))" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>

				<xf:group ref="*[@property = 'time']" class="item northwest">
					<xf:trigger appearance="minimal">
						<xf:label>
							<xf:output value="concat('&lt;img src=&quot;', @icon, '&quot; alt=&quot;', @label, '&quot; /&gt;')" />
						</xf:label>

						<xf:action ev:event="DOMActivate">
							<!--
								TODO: Update the clock gadget to share the hub instance data, then change this xf:setvalue accordingly.
							-->
							<xf:setvalue ref="js:EVENTS_send('backplane-parent-open', concat(instance('inst-params')/position, '|clock|', string(*[@property = 'offset']/*[@property = 'h']), '.', string(*[@property = 'offset']/*[@property = 'm']), ' ', @timezone), instance('inst-scripts')/retval)" value="''" />

							<xf:setvalue bind="script-retval" value="js:EVENTS_send('backplane-close')" />
						</xf:action>
					</xf:trigger>
				</xf:group>
			</xf:group>
		</div>
	</body>
</html>
